﻿using HedgehogTeam.EasyTouch;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CatTouch : MonoBehaviour
{
    public float rotateSpeed = 1f;
    public float scaleSpeed = 0.05f;
    public float maxScale = 2f;
    public float minScale = 0.5f;
    Transform cat;
    private void Awake()
    {
        cat = gameObject.transform;
    }

    public void OnSwipe(Gesture gesture)
    {
        switch (gesture.swipe)
        {
            case EasyTouch.SwipeDirection.None:
                break;
            case EasyTouch.SwipeDirection.Left:
                cat.Rotate(Vector3.up, rotateSpeed );
                break;
            case EasyTouch.SwipeDirection.Right:
                cat.Rotate(Vector3.up, -rotateSpeed );
                break;           
            default:
                break;
        }
    }
    public void OnPinch(Gesture gesture)
    {
        Vector3 scale = cat.localScale;
        if (gesture.deltaPinch > 0 && scale.x <= maxScale)
            scale += Vector3.one * scaleSpeed;
        if(gesture.deltaPinch < 0 && scale.x >= minScale)
            scale -= Vector3.one * scaleSpeed;

        cat.localScale = scale;
        Debug.Log(gesture.deltaPinch);
    }

}
